package my.com.route;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat;
import org.apache.camel.dataformat.bindy.format.FormatException;

import my.com.entity.Broker;

public class BrokerRouteBuilder extends RouteBuilder {

	private static final String DEBUG_ALL_OPTION = "level=DEBUG&showAll=true";

	@Override
	public void configure() throws Exception {
		BindyCsvDataFormat csvDataFormat = new BindyCsvDataFormat(Broker.class);
		
		from("activemq:broker-create").to("bean:implService?method=create");

		from("file://resource?delete=true").filter(body().isNotNull()).to(
				"direct:transform-format");

		from("direct:transform-format").unmarshal().xmljson()
				.to("file://target/result?fileName=$simple{exchangeId}.xml");

		
		 //from("direct:transform-format").processRef("xmlTransformerProcessor")
//		from("direct:transform-format").split(body())
		 //bean
		 //.to("log:APP-1-REKAP-TRANSFORM-FORMAT-LOG?" + DEBUG_ALL_OPTION)
//		 .to("file://target/result?fileName=$simple{exchangeId}.txt");
		//
		// from("direct:persist-data").split(body()).to(
		// "log:APP-1-REKAP-PERSIST-DATA-LOG?" + DEBUG_ALL_OPTION,
		// "jpa://my.com.entity.TransaksiPenjualan");

		// from("activemq:QSource").to("direct:transform-format");
		// from("direct:transform-format").processRef("xmlTransformerProcessor");

	}
}
